Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a way for Shape to preserve user preferred state #1044

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mockoocy
Copy link

The PR introduces user_state attribute that will be set by the web app.
Previously, when the user set grid to be hidden or visible, it set state attribute of Grid class as either HIDDEN or SAVED.
The same attribute was being changed as a result of diffractometer's motors having their state changed, like in the code below:

https://github.com/mxcube/mxcubecore/blob/d9668efbc0ea7c2d66536d9e6224beba212a4c40/mxcubecore/HardwareObjects/SampleView.py#L35C1-L56C35

The new user_state attribute is being intended to be able to be modified by the web app by listening to events such as phaseChanged or collectOscillationFinished in order to restore the state that user wants to see, after these operations are done.

@marcus-oscarsson
Copy link
Member

Could you describe the use case and how this is a problem ?

@marcus-oscarsson
Copy link
Member

The meshes are meant to be automatically hidden/shown when they are within a certain range of the angle where the mesh was created. The meshes are only valid for a certain projection. see

def update_position(self, transform):

This is perhaps not behaving as you wish ?

@elmjag
Copy link
Contributor

elmjag commented Oct 18, 2024

Could you describe the use case and how this is a problem ?

This is an attempt to fix following bug:

  • create a mesh
  • hide the mesh via the hide button
  • do a data collection, say standard oscillation data collection

After the data collection is finished, the mesh will be un-hidden.

The behavior we want is that meshes explicitly hidden by the user are never automatically un-hidden.

@marcus-oscarsson
Copy link
Member

Ah, we should perhaps then add an option to disable the auto hide/show option ?

@elmjag
Copy link
Contributor

elmjag commented Oct 18, 2024

Ah, we should perhaps then add an option to disable the auto hide/show option ?

I think the current behavior is fine. The users so far have not complained about meshes getting hidden during data collections, scans, etc.

It's only the part where all meshes become visible after the scan is finished that annoys users.

Also, here is the MXCuBE-web part of the bug fix: mxcube/mxcubeweb#1460

@marcus-oscarsson
Copy link
Member

It's only the part where all meshes become visible after the scan is finished that annoys users.

I see, is that because all the meshes where created at the same angle or for some other reason. Why is all meshes shown when the collection finishes ?

@elmjag
Copy link
Contributor

elmjag commented Oct 18, 2024

It's only the part where all meshes become visible after the scan is finished that annoys users.

I see, is that because all the meshes where created at the same angle or for some other reason. Why is all meshes shown when the collection finishes ?

Yes, it is a common usage scenario at MicroMAX right now. Users use large chips to collect data. They draw a number of mesh grids at the same angle, as the chip don't rotate.

The reason all mesh grids are made visible, is because the code that auto-hides grids does something like this:

grid.status = "hidden"

Thus the information if a grids was hidden by the user is lost. When code that un-hides grids runs, it shows all grids with correct angle.

@marcus-oscarsson
Copy link
Member

marcus-oscarsson commented Oct 22, 2024

I see, I'm hesitant on adding a user_state. As far as I remember, and I had a quick look, the only place where we update the shape state to "HIDDEN" is in:

def update_position(self, transform):

The drawing of the shapes on the canvas is not performed when the goniometer motors are moving but updated when the state changes to ready. Or did I perhaps leave something out ?

I guess in that case what is causing you this issue is that the state gets changed on rotation, maybe simply adding a option that disables the code above would be enough ?. You could perhaps try to comment out that section and see if it helps ?

@mockoocy
Copy link
Author

I see, I'm hesitant on adding a user_state. As far as I remember, and I had a quick look, the only place where we update the shape state to "HIDDEN" is in:

You are right, the Shape.state is set only in the linked code.

I've talked with @elmjag and the desired functionality looks like this:

  • if user sets grid to HIDDEN manually - keep it hidden always
  • If user sets grid to 'SAVED' - it may become hidden anyways due to rotating (just like it is now)

This would require to store the user's preference somewhere, e.g., in the user_state attribute.

@marcus-oscarsson
Copy link
Member

The problem I see with this feature is that it clashes with the idea of auto hiding. The user would after some time not know which meshes are not being shown because they are auto hidden or explicitly hidden. I guess in that case it should be more evident in the grid list why a grid is hidden. I somehow thing that this might lead to some confusion, thats why I'm a bit hesitant.

It would perhaps be possible to always display a dashed outline of hidden grids or highlight them in the grid table, not sure what would be the best.

@mockoocy mockoocy force-pushed the pm-fix-preserve-mesh-grid-state branch 4 times, most recently from 567bc52 to fae349b Compare October 23, 2024 12:19
@mockoocy
Copy link
Author

mockoocy commented Oct 23, 2024

It would perhaps be possible to always display a dashed outline of hidden grids or highlight them in the grid table, not sure what would be the best.

I think you're right there; I've made some changes on the UI part so that the user-hidden grids appear with a darker background.

I've also pushed some changes to this repository. I've updated the functions that redraw the shapes, to be able to persist the state and user_state attributes.

@mockoocy mockoocy force-pushed the pm-fix-preserve-mesh-grid-state branch from fae349b to b6e2742 Compare October 29, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants